package com.ruanxie.controller.other;

import com.ruanxie.constant.MessageConstant;
import com.ruanxie.entity.Student;
import com.ruanxie.result.Result;
import com.ruanxie.service.OtherService;
import com.ruanxie.vo.user.UserLoginVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 *  其他端
 */
@RestController
@RequestMapping("/api")
@Slf4j
@Api(tags = "其他端")
public class OtherController {

    @Autowired
    private OtherService otherService;

    /**
     * 检验token
     * @param token
     * @return
     */
    @PostMapping("/tokenCheck")
    @ApiOperation("token检验")
    public Result tokenCheck(String token) {
        UserLoginVO userLoginVO =otherService.getUserByToken(token);
        if (userLoginVO!=null) {return Result.success(userLoginVO);}
        else return Result.error(MessageConstant.INVALID_TOKEN_ERROR);
    }
}
